<template>
  <div class="col-sm-12">
    <div class="br_line" style="margin-top:10px;margin-bottom:10px"></div>
    <el-dialog
      title="生成链接成功！"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <span>{{ share_link }}</span>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!--上传 搜索 接收分享 下载 删除 -->
    <div style="text-align:right;margin-bottom:10px;margin-right:8%">
      <!--上传单个或者多个文件  完成  样式待定-->
      <el-popover placement="bottom" width="300" v-model="visible_0">
        <el-form enctype="multipart/form-data" id="fileList" :inline="true">
          <input type="hidden" name="file_path" :value="this.path" /><br />
          <input
            type="file"
            name="files"
            multiple
            style="margin-left:3%"
            :disabled="check_permissions()"
          /><br />
        </el-form>
        <el-tooltip
          class="item"
          effect="light"
          content="注意只能上传到当前目录哦！"
          placement="bottom-start"
        >
          <ElInput
            v-model="this.path"
            placeholder="云盘的目标路径(文件夹)"
            style="margin-bottom:5px"
          ></ElInput>
        </el-tooltip>
        <div style="text-align: right; margin: 0">
          <el-button size="mini" type="text" @click="visible_0 = false"
            >取消</el-button
          >
          <el-button
            type="primary"
            size="mini"
            @click="
              visible_0 = false;
              uploadObject();
            "
            >确定</el-button
          >
        </div>
        <el-button
          type="success"
          slot="reference"
          @click=""
          style="width:98px;margin-right:1%"
          :disabled="check_permissions()"
          >上传文件</el-button
        >
      </el-popover>

      <!--上传文件夹   开发中  样式待定-->
      <el-popover placement="bottom" width="300" v-model="visible_4">
        <form enctype="multipart/form-data" id="fileFolder">
          <input type="hidden" name="file_path" :value="this.path" /><br />
          <input
            type="file"
            name="fileFolderList"
            multiple
            webkitdirectory
            style="margin-left:3%"
            :disabled="check_permissions()"
          /><br />
        </form>
        <el-tooltip
          class="item"
          effect="light"
          content="注意只能上传到当前目录哦！"
          placement="bottom-start"
        >
          <ElInput
            v-model="this.path"
            placeholder="云盘的目标路径(文件夹)"
            style="margin-bottom:5px"
          ></ElInput>
        </el-tooltip>
        <div style="text-align: right; margin: 0">
          <el-button size="mini" type="text" @click="visible_4 = false"
            >取消</el-button
          >
          <el-button
            type="primary"
            size="mini"
            @click="
              visible_4 = false;
              uploadFolder();
            "
            >确定</el-button
          >
        </div>
        <el-button
          type="success"
          slot="reference"
          @click=""
          style="width:110px;margin-right:1%"
          :disabled="check_permissions()"
          >上传文件夹</el-button
        >
      </el-popover>
      <!--模糊搜索  能在控制台显示   但无法通过刷新页面显示-->
      <el-tooltip
          class="item"
          effect="light"
          content="注意只能搜出前20条数据哦！"
          placement="top-start"
        >
      <el-input
        v-model="search_text"
        placeholder="搜索"
        style="width:180px"
        :disabled="check_permissions()"
      ></el-input>
        </el-tooltip>
      <el-button
        type="primary"
        icon="el-icon-search"
        @click="fuzzySearch(path, search_text)"
        style="width:80px;margin-left:-2px;margin-top:1px;margin-right:1%"
        :disabled="check_permissions()"
        >搜索</el-button
      >

      <!--接收分享  完成-->
      <el-popover placement="bottom" width="240" v-model="visible_1">
        <ElInput
          v-model="recive_url"
          placeholder="请输入分享链接"
          style="margin-bottom:5px"
        ></ElInput>
        <el-tooltip
          class="item"
          effect="light"
          content="注意只能接收到当前目录哦！"
          placement="bottom-start"
        >
          <ElInput
            v-model="this.path"
            placeholder="接收分享的路径(包括文件名)"
            style="margin-bottom:5px"
          ></ElInput>
        </el-tooltip>
        <div style="text-align: right; margin: 0">
          <el-button
            size="mini"
            type="text"
            @click="
              visible_1 = false;
              recive_url = '';
            "
            >取消</el-button
          >
          <el-button
            type="primary"
            size="mini"
            @click="
              visible_1 = false;
              receiveShareObject(recive_url);
            "
            >确定</el-button
          >
        </div>
        <el-button
          type="success"
          slot="reference"
          @click=""
          style="margin-right:1%"
          :disabled="check_recive_permission()"
          >接收分享</el-button
        >
      </el-popover>

        <!--新版下载 -->
        <el-popover placement="bottom" width="220" v-model="visible_2">
        <p>确定要下载这些文件吗？</p>
        <p style="color:red;font-weight:800">对于一些媒体文件，需要复制链接手动下载。</p>
        <div style="text-align: right; margin: 0">
          <el-button
            size="mini"
            type="text"
            @click="visible_2 = false"
            >取消</el-button
          >
          <el-button
            type="primary"
            size="mini"
            @click="
              visible_2 = false;
              downLoad_new(check_val);
            "
            >确定</el-button
          >
        </div>
        <el-button
          type="primary"
          slot="reference"
          style="width:98px;margin-right:1%"
          >下载</el-button
        >
      </el-popover>
        

<!--   旧版下载
      
      <el-popover placement="bottom" width="300" v-model="visible_2">
        <el-tooltip
          class="item"
          effect="light"
          content="下载的本地目标路径"
          placement="top-start"
        >
          <ElInput
            v-model="download_path"
            placeholder="输入本地目标路径(文件夹)"
            style="margin-bottom:5px"
          ></ElInput>
        </el-tooltip>
        <div style="text-align: right; margin: 0">
          <el-button
            size="mini"
            type="text"
            @click="visible_2 = false"
            >取消</el-button
          >
          <el-button
            type="primary"
            size="mini"
            @click="
              visible_2 = false;
              downLoad(check_val, download_path);
            "
            >确定</el-button
          >
        </div>
        <el-button
          type="primary"
          slot="reference"
          style="width:98px;margin-right:1%"
          >下载</el-button
        >
      </el-popover>
      -->

      <!--删除  完成-->
      <el-popover placement="bottom" width="160" v-model="visible_3">
        <p>将文件放入回收站？</p>
        <div style="text-align: right; margin: 0">
          <el-button size="mini" type="text" @click="visible_3 = false"
            >取消</el-button
          >
          <el-button
            type="danger"
            size="mini"
            @click="
              visible_3 = false;
              deleteObject(check_val);
            "
            >确定</el-button
          >
        </div>
        <el-button
          type="primary"
          slot="reference"
          style="width:98px;margin-right:1%"
          @click=""
          :disabled="check_permissions()"
          >删除</el-button
        >
      </el-popover>
    </div>

    <div class="card-box">
      <table class="table">
        <thead>
          <tr>
            <th style="width:20px"></th>
            <th style="width:30px"></th>
            <th style="width:42%">文件名</th>
            <th>作者</th>
            <th>大小</th>
            <th>更新时间</th>
            <th style="width:23%">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, index) in data" :key="index" ref="table">
            <input
              type="checkbox"
              style="margin-top:15px"
              :value="item"
              v-model="check_val"
            />

            <td v-if="check_suffix(item.fileType) == 'text'">
              <i class="el-icon-notebook-2" style="margin-top:7px"></i>
            </td>
            <td v-if="check_suffix(item.fileType) == 'photo'">
              <i class="el-icon-picture-outline" style="margin-top:7px"></i>
            </td>
            <td v-if="check_suffix(item.fileType) == 'video'">
              <i class="el-icon-video-camera" style="margin-top:7px"></i>
            </td>
            <td v-if="check_suffix(item.fileType) == 'folder'">
              <i class="el-icon-folder" style="margin-top:7px"></i>
            </td>
            <td v-if="check_suffix(item.fileType) == ''">
              <i class="el-icon-document-remove" style="margin-top:7px"></i>
            </td>

            <td class="middle-align">
              <a
                v-if="check_suffix(item.fileType) == 'folder'"
                @click="$parent.getData(item.pathName + '/')"
                style="cursor:pointer"
                >{{ item.fileName }}</a
              >
              <a
                v-if="
                  check_suffix(item.fileType) == 'text' ||
                    check_suffix(item.fileType) == 'photo' ||
                    check_suffix(item.fileType) == 'video'
                "
                @click="preView(3600, item.pathName)"
                style="cursor:pointer"
              >
                {{ item.fileName }}
              </a>
              <a v-if="check_suffix(item.fileType) == ''">{{
                item.fileName
              }}</a>
            </td>
            <td>{{ item.author }}</td>
            <td v-if="item.fileSize != null">
              {{ displaySize(item.fileSize) }}
            </td>
            <td v-if="item.fileSize == null">———</td>
            <td>{{ item.lMtime }}</td>
            <td>
              <!--分享  完成  但显示链接的方式有待完善-->
              <el-popover placement="top" width="180">
                <el-select
                  v-model="value"
                  placeholder="请选择分享时限"
                  style="margin-bottom:5px"
                >
                  <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
                <div style="text-align: right; margin: 0">
                  <el-button
                    type="primary"
                    size="mini"
                    @click="
                      shareObject(value, item.pathName);
                      dialogVisible = true;
                    "
                    >确定</el-button
                  >
                </div>
                <el-button
                  type="primary"
                  size="mini"
                  slot="reference"
                  :disabled="check_permissions()"
                  >分享</el-button
                >
              </el-popover>

              <!--复制  完成-->
              <el-popover placement="top" width="250">
                <ElInput
                  v-model="copy_text"
                  placeholder="目标路径(包括文件名)"
                  style="margin-bottom:5px"
                ></ElInput>
                <div style="text-align: right; margin: 0">
                  <el-button
                    type="primary"
                    size="mini"
                    @click="copyObject(item.pathName, copy_text)"
                    >确定</el-button
                  >
                </div>
                <el-button
                  type="primary"
                  size="mini"
                  slot="reference"
                  :disabled="check_permissions()"
                  >复制</el-button
                >
              </el-popover>

              <!--移动  完成-->
              <el-popover placement="top" width="250">
                <ElInput
                  v-model="move_text"
                  placeholder="目标路径(包括文件名)"
                  style="margin-bottom:5px"
                ></ElInput>
                <div style="text-align: right; margin: 0">
                  <el-button
                    type="primary"
                    size="mini"
                    @click="moveObject(item.pathName, move_text)"
                    >确定</el-button
                  >
                </div>
                <el-button
                  type="primary"
                  size="mini"
                  slot="reference"
                  :disabled="check_permissions()"
                  >移动</el-button
                >
              </el-popover>

              <!--重命名  完成-->
              <el-popover placement="top" width="160">
                <ElInput
                  v-model="rename_text"
                  placeholder="请输入新的名称"
                  style="margin-bottom:5px"
                ></ElInput>
                <div style="text-align: right; margin: 0">
                  <el-button
                    type="primary"
                    size="mini"
                    @click="
                      renameObject(item.pathName, item.path + rename_text)
                    "
                    >确定</el-button
                  >
                </div>
                <el-button
                  type="primary"
                  size="mini"
                  slot="reference"
                  @click=""
                  :disabled="check_permissions()"
                  >重命名</el-button
                >
              </el-popover>
            </td>
          </tr>
        </tbody>
      </table>
      
        <div class="block" align="center" >
            <el-pagination
            v-if="disabled_fuzzy==true"
                :page-size="10"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :total="parseInt(this.total)"
                layout="prev, pager, next"
                >
            </el-pagination>
        </div>

    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      visible_0: false,
      visible_1: false,
      visible_2: false,
      visible_3: false,
      visible_4: false,
      dialogVisible: false,
      rename_text: "",
      copy_text: this.path,
      recive_url: "",
      recive_path: "",
      move_text: this.path,
      search_text: "",
      download_path: "D://Taoyun/",
      upload_path: this.path,
      delete_text: "",
      share_link: "",
      upload_folder_path: this.path,
      check_val: [],

      options: [
        {
          value: "86400",
          label: "一天"
        },
        {
          value: "259200",
          label: "三天"
        },
        {
          value: "-1",
          label: "永久"
        }
      ],
      value: "",
      page_data: "",
      currentPage:1,
        disabled_fuzzy:true,
    };
  },
  props: ["data", "path", "userInfo","total"],
  methods: {
      // 点击页面数显示
    handleCurrentChange: function(currentPage) {
        this.$parent.getData(this.path,currentPage);
      },
    // 除了下载按钮  其他都要加这个disabled   true==不可操作   false==可以操作
    check_permissions() {
      // 在public及其子路径下，管理员和员工只能下载和查看（其他按钮变disabled）
      if (this.path.substr(0, 6) == "public") {
        if (this.userInfo.permission == "超管") {
          return false;
        } else {
          return true;
        }
      }

      // 在groups及其子路径下，超管只能下载和查看（其他按钮变disabled）
      else if (this.path.substr(0, 6) == "groups") {
        if (this.userInfo.permission == "超管") {
          return true;
        } else {
          return false;
        }
      } else if (this.path.substr(0, 4) == "user") {
        return false;
      }
    },
    // 接收分享按钮只能在个人文件夹下点开接收
    check_recive_permission() {
      if (this.path.substr(0, 4) == "user") {
        return false;
      } else {
        return true;
      }
    },
    open_success(mes) {
      this.$notify.success({
        title: "成功",
        message: mes,
        position: "bottom-right"
      });
    },
    open_error(mes) {
      this.$notify.error({
        title: "错误",
        message: mes,
        position: "bottom-right"
      });
    },

    // 转换字节为KB MB GB
    displaySize(size) {
      // 小于1M的情况  显示KB
      if (size <= 1048575) {
        return (size / 1024).toFixed(2) + "KB";
      }
      // 小于1G的情况  显示MB
      else if (1048575 < size && size <= 1073741823) {
        return (size / (1024 * 1024)).toFixed(2) + "MB";
      }
      // 大于1G的情况  显示GB
      else {
        return (size / (1024 * 1024 * 1024)).toFixed(2) + "GB";
      }
    },

    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },

    check_suffix(suffix) {
      if (suffix == "txt") {
        return "text";
      } else if (
        suffix == "png" ||
        suffix == "jpg" ||
        suffix == "jpeg" ||
        suffix == "gif"
      ) {
        return "photo";
      } else if (suffix == "mp4") {
        return "video";
      } else if (suffix == "folder") {
        return "folder";
      } else {
        return "";
      }
    },

    // 检测到token失效，跳转到登录页
    jump_to_login() {
      let that = this;
      this.open_error("认证已经过期，2秒后自动跳转到登录页面");
      setTimeout(function() {
        that.$router.push({ path: "/signin" });
      }, 2000);
    },

    // 上传文件  完成
    uploadObject() {
      var form = document.getElementById("fileList");
      var formData = new FormData(form);

      this.$axios
        .post("/api/taoyun/v1/uploads", formData)
        .then(res => {
          if (res.data.code == "200") {
            this.open_success(res.data.data + "，页面将在2S后自动刷新");
            setTimeout(function() {
              location.reload();
            }, 2000);
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查上传的文件大小或路径是否存在问题！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    // 上传文件夹
    uploadFolder() {
      var form = document.getElementById("fileFolder");
      var formData = new FormData(form);

      this.$axios
        .post("/api/taoyun/v1/uploadFolder", formData)
        .then(res => {
          if (res.data.code == "200") {
            this.open_success(res.data.data + "，页面将在2S后自动刷新");
            setTimeout(function() {
              location.reload();
            }, 2000);
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查上传的文件大小或路径是否存在问题！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    // 模糊搜索
    fuzzySearch(now_path, file_name) {
        this.disabled_fuzzy=false;
      this.$axios
        .get("/api/taoyun/v1/File/searchfile_byName", {
          params: {
            now_path,
            file_name,
            page:1,
            size:20,
          }
        })
        .then(res => {
          if (res.data.code == "200") {
            this.$parent.setItems(res.data.data.list);
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          this.open_error("服务器宕机了...请稍后再试。");
        });
    },

    // 预览
    preView(seconds, objectPath) {
      this.$axios
        .get("/api/taoyun/v1/getObjectLink", {
          params: {
            expireSeconds: seconds,
            objectName: objectPath
          }
        })
        .then(res => {
          window.open(res.data.data);
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    // 下载文件  新版
    downLoad_new(item){
        if (item == "") {
            this.open_error("下载的文件不能为空！");
            return;
        }
        if(item.length>3){
            this.open_error("一次最多只能下载三个文件哦！");
            return;
        }
        console.log('item :>> ', item);
        for(let i=0;i<item.length;i++){
            if(item[i].fileType=="folder"){
                this.open_error("抱歉，涛云目前不支持下载文件夹，或许您可以尝试压缩文件。")
                return;
            }
        }

        var objectNames='';
        for(let i=0;i<item.length;i++){
            if(i!=item.length-1){
                objectNames+=item[i].pathName+',';
            }
            else{
                objectNames+=item[i].pathName;
            }
        }

        this.open_success("准备开始下载，请稍等...");

        this.$axios.get('/api/taoyun/v1/getDownloadLink', {
            params: {
                objectNames
            }
        })
        .then((res) => {
           if(res.data.code=='200'){
               let dataInfo=res.data.data;
               for(let i=0;i<dataInfo.length;i++){
                    window.open(dataInfo[i]);
               }
           }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    // 下载文件  旧版  打包上传到服务器不可用
    downLoad(item,fileLocatePrefix) {
      var form = document.getElementById("downLoadFile");
      if (item == "") {
        this.open_error("下载的文件不能为空！");
        return;
      }
      var objectNames = "";
      for (let i = 0; i < item.length; i++) {
        if (item[i].fileType == "folder") {
          let obj = item[i].pathName + "/";
          objectNames += obj + ",";
        } else {
          objectNames += item[i].pathName + ",";
        }
      }
      this.$axios
        .get("/api/taoyun/v1/downloadfile", {
          params: {
            bucketName: "taoyun",
            objectNames,
            fileLocatePrefix
          }
        })
        .then(res => {
          if (res.data.code == "200") {
            this.open_success("下载成功！");
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    //复制文件
    copyObject(sobj, dobj) {
      var formData = new FormData();
      formData.append("sobj", sobj);
      formData.append("dobj", dobj);

      this.$axios
        .put("/api/taoyun/v1/copyfile", formData)
        .then(res => {
          if (res.data.code == "201") {
            this.open_success(res.data.msg);
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    //移动
    moveObject(sobj, dobj) {
      var formData = new FormData();
      formData.append("sobj", sobj);
      formData.append("dobj", dobj);

      this.$axios
        .put("/api/taoyun/v1/movefile", formData)
        .then(res => {
          if (res.data.code == "202") {
            this.open_success(res.data.msg + "，页面将在2S后自动刷新");
            setTimeout(function() {
              location.reload();
            }, 2000);
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    //重命名
    renameObject(objectName, newObjectName) {
      if (newObjectName == "" || newObjectName == null) {
        this.open_error("名称不能为空！");
      } else {
        var formData = new FormData();
        formData.append("objectName", objectName);
        formData.append("newObjectName", newObjectName);

        this.$axios
          .put("/api/taoyun/v1/renameObject", formData)
          .then(res => {
            if (res.data.code == "200") {
              this.open_success(res.data.msg + "，页面将在2S后自动刷新");
              setTimeout(function() {
                location.reload();
              }, 2000);
            } else if (res.data.code == "500") {
              this.open_error(res.data.msg);
            }
          })
          .catch(err => {
            if (err.response) {
              if (err.response.data.msg == null) {
                this.open_error("请检查该文件是否已经被改动！");
              } else if (
                err.response.data.msg ==
                "Jedis 客户端连接异常/头部没有tokenLogin"
              ) {
                this.jump_to_login();
              } else {
                this.open_error(err.response.data.msg);
              }
            }
          });
      }
    },

    //移到回收站
    deleteObject(item) {
      var ids = new Array();
      for (let i = 0; i < item.length; i++) {
        ids.push(item[i].fileId);
      }
      var formData = new FormData();
      formData.append("fileIds", ids);

      this.$axios
        .put("/api/taoyun/v1/put-recycle-bin", formData)
        .then(res => {
          if (res.data.code == "200") {
            this.open_success(res.data.msg + "，页面将在2S后自动刷新");
            setTimeout(function() {
              location.reload();
            }, 2000);
          } else if (res.data.code == "401") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    //分享
    shareObject(expireSeconds, objectName) {
      this.$axios
        .get("/api/taoyun/v1/getObjectLink", {
          params: {
            expireSeconds,
            objectName
          }
        })
        .then(res => {
          if (res.data.code == "200") {
            // this.open_share(res.data.data);
            this.share_link = res.data.data;
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    },

    //接收分享
    receiveShareObject(url) {
      var formData = new FormData();
      formData.append("url", url);
      formData.append("dobj", this.path);

      this.$axios
        .put("/api/taoyun/v1/shareobject", formData)
        .then(res => {
          if (res.data.code == "200") {
            this.open_success(res.data.msg + "，页面将在2S后自动刷新");
            setTimeout(function() {
              location.reload();
            }, 2000);
          } else if (res.data.code == "500") {
            this.open_error(res.data.msg);
          }
        })
        .catch(err => {
          if (err.response) {
            if (err.response.data.msg == null) {
              this.open_error("请检查该文件是否已经被改动！");
            } else if (
              err.response.data.msg == "Jedis 客户端连接异常/头部没有tokenLogin"
            ) {
              this.jump_to_login();
            } else {
              this.open_error(err.response.data.msg);
            }
          }
        });
    }
  }
};
</script>
<style scoped>
.box {
  width: 400px;

  .bottom {
    clear: both;
    text-align: center;
  }
}
.btn-near {
  margin-right: 0;
}
.selBtn {
  margin-top: 10px;
}
.el-upload__input {
  display: none;
}
.br_line {
  /*内嵌水平线*/
  width: 90%;
  margin: 0 auto;
  border: 0;
  height: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.upload_box {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  background-color: #e0f0e9;
}
</style>
